{#
 # ---------------------------------------------------------------------
 #
 # GLPI - Gestionnaire Libre de Parc Informatique
 #
 # http://glpi-project.org
 #
 # @copyright 2015-2025 Teclib' and contributors.
 # @licence   https://www.gnu.org/licenses/gpl-3.0.html
 #
 # ---------------------------------------------------------------------
 #
 # LICENSE
 #
 # This file is part of GLPI.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #
 # ---------------------------------------------------------------------
 #}

{% import 'components/form/fields_macros.html.twig' as fields %}

<form method="POST" action="{{ item.getFormURL() }}" data-submit-once>
    <div class="py-2 px-3 container-narrow ms-0">
        <section data-service-catalog-config
            style="{{ item.isField('show_in_service_catalog') and item.fields.show_in_service_catalog ? "opacity: 0.5" : "" }}"
        >
            <h2 class="d-flex align-items-center">
                <i class="{{ icon }} me-2"></i>
                {{ __("Service catalog configuration") }}
                {% if item.isField('show_in_service_catalog') %}
                    <label class="form-check mb-0 ms-auto form-switch">
                        <input type="hidden" value="0" name="show_in_service_catalog">
                        <input aria-label="{{ __(" Active") }}" class="form-check-input" type="checkbox"
                            name="show_in_service_catalog" value="1"
                            onchange="$('[data-service-catalog-config]').css('opacity', this.checked ? 1 : 0.5)"
                            {{ item.fields.show_in_service_catalog == true ? "checked" : "" }}
                        >
                    </label>
                {% endif %}
            </h2>
            <div class="row">
                <div class="col-lg-10 col-12">
                    {{ fields.textareaField(
                        'description',
                        item.fields.description,
                        __('Description'),
                        {
                            'is_horizontal': false,
                            'full_width' : true,
                            'enable_richtext': true,
                            'enable_images': false,
                        }
                    ) }}
                </div>

                <div class="col-lg-2 col-12">
                    {{ fields.illustrationField(
                        'illustration',
                        item.getServiceCatalogItemIllustration(),
                        __('Illustration'),
                        {
                            'is_horizontal': false,
                            'full_width' : true,
                            'extra_css_classes': 'illustration-selector-extra-margin',
                        }
                    ) }}
                </div>
            </div>

            {{ fields.dropdownField(
                'Glpi\\Form\\Category',
                'forms_categories_id',
                item.fields.forms_categories_id,
                _n('Category', 'Categories', 1),
                {
                    'is_horizontal': false,
                    'full_width' : true,
                }
            ) }}

            <label class="col-form-label form-check form-switch mb-2">
                <input type="hidden" name="is_pinned" value="0">
                <input class="form-check-input" type="checkbox" name="is_pinned" value="1" {{ item.fields.is_pinned ? 'checked' : '' }}>
                <span class="form-check-label">{{ __("Pin to top of the service catalog") }}</span>
            </label>
        </section>

        {# Hidden values #}
        <input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}" />
        <input type="hidden" name="id" value="{{ item.getID() }}" />

        {# Actions #}
        <div class="d-flex mt-4">
            <button type="submit" name="update" class="btn btn-primary ms-auto">
                <i class="ti ti-device-floppy me-1 "></i>
                {{ __("Save changes") }}
            </button>
        </div>
    </div>
</form>
